# frozen-string-literal:true
10.times do |i|
  print(<<~"EOB")
    i:#{i}
  EOB
end
# 创建长字符串，包含回车换行
str = <<-EOB
Hello!
Hello!\n
Hello!
EOB
puts str
p sprintf("%#010x", 100)

str = "AA\nBB\nCC\n"
p str.each_byte.reject{|c| c==0x0a}
p str.each_line.map{|line| line.chomp!}

p str.object_id
str = "adf"
p str.object_id
p str.upcase
str = "Ruby    is an object oriented programming language"
p str.split(/\s+/)
def to_capital(str)
  ary = str.split(/\s+/)
  ary.map{|item| item.capitalize! }
  ary.join(' ')
end
p to_capital(str)

h = Hash.new(0)
h['a'] = "132"
p h["not_key"]
p h[0]
p h['a']
p h

h = {foo: 0, bar: 1, baz: 2}
e = h.reject!
p e.each{|key, value| key.start_with?('b')}
p h

# 计算单词数量
# count = Hash.new(0)
# # 统计单词
# File.open(ARGV[0]) do |f|
#   f.each_line do |line|
#     words = line.split
#     words.each do|word|
#       count[word] += 1
#     end
#   end
# end
# # 输出结果
# result = count.sort do |a,b|
#   a[1] <=> b[1]
# end
# result.each do |key, value|
#   print("#{key}: #{value}\n")
# end

wday = {
  Monday:'星期一',
  Theusday:'星期二',
  Wednesday:'星期三',
  Thursday:'星期四',
  Firday: '星期五',
  Saturday:'星期六',
  Sunday:'星期日'
}
p wday